#include <iostream>
#include <string>
#include <stack>

int main() {
    std::string a;
    std::getline(std::cin, a);
    std::stack<char> stack;
    bool ans = true;
    for (size_t i = 0; i < a.length(); ++i) {
        if (a[i] == '(') {
            stack.push(a[i]);
        } else if (a[i] == ')') {
            if (!stack.empty() && stack.top() == '(') {
                stack.pop();
            } else {
                ans = false;
                break;
            }
        }
        if (a[i] == '{') {
            stack.push(a[i]);
        } else if (a[i] == '}') {
            if (!stack.empty() && stack.top() == '{') {
                stack.pop();
            } else {
                ans = false;
                break;
            }
        }
        if (a[i] == '[') {
            stack.push(a[i]);
        } else if (a[i] == ']') {
            if (!stack.empty() && stack.top() == '[') {
                stack.pop();
            } else {
                ans = false;
                break;
            }
        }
        if (a[i] == '<') {
            stack.push(a[i]);
        } else if (a[i] == '>') {
            if (!stack.empty() && stack.top() == '<') {
                stack.pop();
            } else {
                ans = false;
                break;
            }
        }
    }
    if (stack.empty() && ans) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}

